package title;

import java.util.Scanner;

/**
 * @author 111
 * @version 1.0
 * @date 2025/4/14 20:00
 * @description
 */
public class Test08 {
    public static void main(String[] args) {
        User[] all = new User[3];
        all[0] = new User("powernode","123");
        all[1] = new User("chailinyan","8888");
        all[2] = new User("java","6666");
        for (int i = 0; i < all.length; i++) {
            System.out.println(all[i]);
        }

        Scanner input =new Scanner(System.in);
        System.out.print("请输入用户名：");
        String username = input.next();
        System.out.print("请输入密码：");
        String password = input.next();

        boolean flag = false;
        for (int i = 0; i < all.length; i++) {
            if(all[i].getUsername().equals(username) && all[i].getPassword().equals(password)){
                flag = true;
                break;
            }
        }
        System.out.println("登录结果：" +flag);
        input.close();
    }
}
class User{
    private String username;
    private String password;
    public User(String username, String password) {
        super();
        this.username = username;
        this.password = password;
    }
    public User() {
        super();
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    @Override
    public String toString() {
        return username + "-" + password;
    }

}
